package cn.ubeta.b2c.user.order;

import android.content.Context;
import android.os.Bundle;

import cn.ubeta.b2c.R;
import cn.ubeta.b2c.api.ApiOrder;
import cn.ubeta.b2c.bean.OrderDetailInfo;
import cn.ubeta.b2c.common.AnalyseActivity;
import cn.ubeta.b2c.utils.NetworkCallback;

import java.io.IOException;

/**
 * Created by denny on 16/9/6.
 */

public class OrderDetailActivity extends AnalyseActivity {

    private final static String ARG_ORDER_ID = "order_id";

    private int mOrderId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_order_detail);

        mOrderId = getIntent().getIntExtra(ARG_ORDER_ID, 0);

        refreshView();
    }

    /**
     * 刷新视图
     */
    private void refreshView() {
        ApiOrder.getOrderDetail(mOrderId, new NetworkCallback<OrderDetailInfo>() {
            @Override
            public void onResponse(OrderDetailInfo info) {
                bindView(info);
            }

            @Override
            public void onFailure(IOException e) {

            }
        });
    }

    /**
     * 绑定订单数据到视图
     * @param info
     */
    private void bindView(OrderDetailInfo info) {
        // TODO 绑定订单数据到视图
    }

    /**
     * 跳转到订单详情
     * @param context
     * @param orderId
     */
    public static void gotoOrderDetail(Context context, int orderId) {
        Bundle data = new Bundle();
        data.putInt(ARG_ORDER_ID, orderId);
        gotoActivity(context, OrderDetailActivity.class, data);
    }
}